home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1998 September / EnigmA AMIGA RUN 30 (1998)(G.R. Edizioni)(IT)[!][issue 1998-09].iso / recent / nc-11u1.lha / nc-1.1 / scripts / iscan < prev    next >
Text File  |  1998-07-15  |  1KB  |  36 lines

  1. #! /bin/sh
  2. ## duplicate DaveG's ident-scan thingie using netcat.  Oooh, he'll be pissed.
  3. ## args: target port [port port port ...]
  4. ## hose stdout *and* stderr together.
  5. ##
  6. ## advantages: runs slower than ident-scan, giving remote inetd less cause
  7. ## for alarm, and only hits the few known daemon ports you specify.
  8. ## disadvantages: requires numeric-only port args, the output sleazitude,
  9. ## and won't work for r-services when coming from high source ports.
  10.  
  11. case "${2}" in
  12.   "" ) echo needs HOST and at least one PORT ; exit 1 ;;
  13. esac
  14.  
  15. # ping 'em once and see if they *are* running identd
  16. nc -z -w 9 "$1" 113 || { echo "oops, $1 isn't running identd" ; exit 0 ; }
  17.  
  18. # generate a randomish base port
  19. RP=`expr $$ % 999 + 31337`
  20.  
  21. TRG="$1"
  22. shift
  23.  
  24. while test "$1" ; do
  25.   nc -v -w 8 -p ${RP} "$TRG" ${1} < /dev/null > /dev/null &
  26.   PROC=$!
  27.   sleep 3
  28.   echo "${1},${RP}" | nc -w 4 -r "$TRG" 113 2>&1
  29.   sleep 2
  30. # does this look like a lamer script or what...
  31.   kill -HUP $PROC
  32.   RP=`expr ${RP} + 1`
  33.   shift
  34. done
  35.  
  36.